package top.jsjkxyjs.blackbox.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.jsjkxyjs.blackbox.entity.Event;
import top.jsjkxyjs.blackbox.entity.User;
import top.jsjkxyjs.blackbox.mapper.EventMapper;
import top.jsjkxyjs.blackbox.service.EventService;

import java.util.List;

@Service
public class EventServiceImpl implements EventService {
	@Autowired
	EventMapper eventMapper;

	@Override
	public List<Event> getAllEvents() {
		List<Event> events = eventMapper.getAllUnhandledEvent();
		return events;
	}

	@Override
	public Event insertEvent(Event event) {
		eventMapper.insert(event);
		return event;
	}

	@Override
	public boolean eventEnd(User user, int id) {

		return eventMapper.eventEnd(id, user.getId()) > 0;
	}
}
